package com.hy.main.demo.io;

import org.junit.Test;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

/**
 * @Author shy Boy
 * @Date 2022/4/26 - 04 - 26 - 20:45
 * @Description: com.hy.main.demo.file
 * @version: 1.0
 */
public class BufferedReaders {

    @Test
    public void reader() {
        String s = "15120220418560000      浦银安盛中证智能电动汽车ETF                                 0000000079330000000000007933000000000000000000000000000000000000000000000000000000000000000000000000000000000000";
        String i = "02020220418006464006464浦银普益A                                                   0000000103080000000000011168000000000000000000000000000000000000000000000000000000000000000000000000000000000000";
        String j = "07720220414012787012787浦银安盛泰和配置6个月持有混合（FOF）A                       0000000089860000000000008986000000000000000000000000000000000000000000000000000000000000000000000000000000000000";
        System.out.println(s.length());
        System.out.println(i.length());
        System.out.println(j.length());

        BufferedReader bufferedReader = null;
        try {
            String path = "E:\\myFile.txt";
            bufferedReader = new BufferedReader(new FileReader(path));
            String lineData = null;
            // 按行读取
            while ((lineData = bufferedReader.readLine())!=null) {
                System.out.println(lineData);
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                // 这边的关闭也会去关闭FileReader
                bufferedReader.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
